﻿using System;

namespace LibraryGuard.Interfaces
{
	/// <summary>
	/// Mode states.
	/// </summary>
	public enum ModeState
	{
		Stopped,
		Running,
		Paused
	}

	/// <summary>
	/// Interface for execution modes, see <see cref="LibraryGuard.Interfaces.Configuration.Mode"/>.
	/// </summary>
	/// <remarks>
	/// <para>Mode should do calculations on other thread, each method except <see cref="LibraryGuard.Interfaces.IMode.Stop"/>
	/// should return as fast as possible.</para>
	/// 
	/// <para>Necessary transitions:
	/// Stopped -> Running
	/// Running -> Stopped
	/// Running -> Paused
	/// Paused  -> Running
	/// Paused  -> Stopped
	/// </para>
	/// </remarks>
	public interface IMode
		: IDisposable
	{
		/// <summary>
		/// Current mode state.
		/// </summary>
		ModeState State { get; }

		/// <summary>
		/// Starts.
		/// </summary>
		void Start();

		/// <summary>
		/// Stops(permanently).
		/// </summary>
		/// <remarks>
		/// Should wait for threads.
		/// </remarks>
		/// <param name="forceStop">If true, method should stop all threads ASAP.</param>
		void Stop(bool forceStop);

		/// <summary>
		/// Pauses execution.
		/// </summary>
		void Pause();

		/// <summary>
		/// Resumes.
		/// </summary>
		void Resume();
	}
}
